
package codeGenerate.custom.converter.impl;

import java.util.ArrayList;
import java.util.List;

import codeGenerate.common.utils.SystemUtils;
import codeGenerate.custom.converter.CustomConverter;
import codeGenerate.custom.vo.CustomPropertyVo;

/**
 * 中文的自定义转换器，将字段字符串转化成类字段集合
 * <p>支持如下格式：</p>
 * <p>医院标示</p>
 * @author fudewei
 */
public class ChineseCustomConverter implements CustomConverter {

	@Override
	public List<CustomPropertyVo> convert(String fieldStr) {

		List<CustomPropertyVo> list = new ArrayList<>();
		String[] columnlines = fieldStr.trim().split("\n");
		for (String columnline : columnlines) {
			columnline = columnline.trim();
			CustomPropertyVo packageColumnVo = new CustomPropertyVo();
			packageColumnVo.setJavaPropertyComment(columnline);
			//替换掉特殊字符,避免干扰列编码
			packageColumnVo.setJavaPropertyName(SystemUtils.chineseToClassFieldName(columnline));
			//由于只有中文一列，和javaPropertyName一样
			packageColumnVo.setOrginalPropertyName(packageColumnVo.getOrginalPropertyName());

			packageColumnVo.setJavaPropertyType("String");
			list.add(packageColumnVo);
		}
		return list;
	}

}
